package com.per.mybootall.test;

import java.util.concurrent.*;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: yyy
 * Date: 2021/12/22
 * Time: 14:40
 * Description:线程池测试
 */
public class test05 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService exe= Executors.newFixedThreadPool(3);
        Callable run=new Callable() {

            @Override
            public Object call() throws Exception {
                System.out.println("这是有返回值的Callable");
                return "Callable";
            }
        };
        Runnable run1=new Runnable() {
            @Override
            public void run() {
                System.out.println("456");
            }
        };

        Future<String> future = exe.submit(run);
        System.out.println("返回的值为------>"+future.get());
        exe.execute(run1);
        exe.execute(run1);
        exe.execute(run1);
        exe.shutdown();

    }
}
